/*
 * Created: 2024/7/23
 * Author:  hineven
 * See LICENSE for licensing.
 */

#ifndef MIRENDERER_MI_H
#define MIRENDERER_MI_H
#include "core/common.h"
#include "core/inftra.h"
#include "mi/mi_fwd.h"

MI_NAMESPACE_BEGIN

class Mesh;
class StaticMesh;
// Procedural mesh, the user needs to handle mesh hashing / updates / LODs.
class ProceduralMesh;

// Geometry: a series of vertices - indices. Can be dynamic / static.

// Mesh: a series of geometries - material refs, specifying a reusable object that's bound together.

// GenericMaterial: a template for a material for geometries. Deferred / Forward, triangles / lines, different shading logic, etc.

// Material: an instance of a material, with varying material parameters.

// Light: light that is invisible to the renderer, but affects the scene.

// Renderable: the input commands given to the renderer, specifying a mesh/light - transform pair for final rendering.

// The overall renderer class.
class MIRenderer {
public:
    MaterialRootRef CreateMaterialRoot () ;

    MeshRef CreateMesh (MeshCreateInfo) ;
    LightRef CreateLight (LightCreateInfo) ;

    // Start the renderer.
    void Start () ;

    // Synchronize a frame (block until the render commands for the previous frame is submitted and the next frame
    // is ready for recording.)
    void SynchronizeFrame () ;


protected:
    void Run () ;

    std::unique_ptr<std::thread> rendering_thread_;

};

std::unique_ptr<MIRenderer> CreateRenderer (std::unique_ptr<MIInfraInterface> infra);

MI_NAMESPACE_END

#endif //MIRENDERER_MI_H
